package com.xia.controller;

import com.xia.po.BankInfo;
import com.xia.service.BankService;
import com.xia.util.ExcelUtil;
import io.swagger.annotations.*;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@Api(tags = "导入Excel文件")
@Slf4j
public class ImportExcelController {

    @Autowired
    private BankService bankService;

    @Autowired
    private ExcelUtil excelUtil;

    @PostMapping(value = "/uploadExcel")
    public String uploadExcel(@ApiParam(value = "用户信息Excel导入数据", required = true) MultipartFile file) throws Exception {
       /* List<BankInfo> dtoList = excelUtil.readExcelFileToDTO(file, BankInfo.class);
        log.info("长度："+dtoList.size());

        for (BankInfo bankInfo : dtoList) {
            System.out.println(bankInfo+"********");
        }*/
        bankService.insertList(file);
        return "导入成功";
    }

}
